Skip to content

fix(renderers): align numeric table cells with headers - #1051

Merged
stranske merged 1 commit into
mainfrom
codex/issue-1044-table-cell-alignment
Sep 12, 2026
Merged

stranske merged 1 commit into
mainfrom
codex/issue-1044-table-cell-alignment

Conversation

@stranske

@stranske stranske commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Workflow Source

Started from:

Automation intent:

  • Verifier should review this
  • Keepalive may manage this PR

Summary

Closes #1044.

CPRS-CH and CPRS-FCM PNG tables currently left-align numeric values beneath right-aligned headers. Position data-cell text using the column alignment and rendered text width so amounts share the header's right padding. Counterparty names retain their left padding.

Tasks and Acceptance Criteria

  • Apply right-aligned positioning to numeric data cells in the shared table renderer.
  • Verify drawing coordinates for both table types with plain, currency, and accounting formats, including negative and zero values.
  • Decode generated PNGs and assert actual numeric glyph positions reach the same right padding as headers; counterparty names remain left-aligned.
  • uv run pytest tests/renderers/test_table_png.py -q: 45 passed.
  • Deliberate-break gate: restore the original renderer while keeping the new tests; all 8 alignment cases fail. Restore the fix; all 45 tests pass.

Testing

Used the existing Python 3.12.2 environment with UV_PROJECT_ENVIRONMENT and UV_NO_SYNC=1; verified the imported renderer resolves to this branch worktree. The full tests/renderers directory contains the same 45 tests and passes. Focused Black, Ruff, mypy, and git diff --check pass. Visually inspected a generated sample with both rows of differing numeric widths.

Local validation evidence: /Users/teacher/.codex/automations/pd-workloop-resume/artifacts/20260912T0901Z/ (test and mutation logs plus aligned-table.png). CI and automated review are pending; keepalive owns the next pass. No auto-merge is armed.

Summary by CodeRabbit

  • Bug Fixes

    • Numeric values in rendered tables now align to the right edge of their columns when configured, improving readability.
    • Text-based values continue to use left alignment.
  • Tests

    • Added coverage validating alignment across supported PNG table renderers, including pixel-level rendering checks.

@stranske stranske added agent:codex Assign to Codex agent agents:keepalive Enable keepalive monitoring on PR autofix Let bots format/lint automatically codex labels Sep 12, 2026
Copilot AI lite review requested due to automatic review settings September 12, 2026 09:09
@stranske stranske added autofix Let bots format/lint automatically codex labels Sep 12, 2026
@stranske
stranske deployed to agent-standard September 12, 2026 09:09 — with GitHub Actions Active
@stranske
stranske deployed to agent-standard September 12, 2026 09:09 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 212ab155-77cc-476f-bd93-8a50a0704267

📥 Commits

Reviewing files that changed from the base of the PR and between a846d4b and 133def9.

📒 Files selected for processing (2)
  • src/counter_risk/renderers/table_png.py
  • tests/renderers/test_table_png.py

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


📝 Walkthrough

Walkthrough

The PNG table renderer now right-aligns data cells when their columns use right-aligned headers. Tests validate draw coordinates and rendered PNG pixels for both renderers and multiple formatting profiles.

Changes

Numeric table cell alignment

Layer / File(s) Summary
Alignment rendering and validation
src/counter_risk/renderers/table_png.py, tests/renderers/test_table_png.py
The renderer positions right-aligned cell text against the cell’s right boundary. Tests verify left-aligned counterparty text, right-aligned numeric text, draw coordinates, PNG scanlines, and rendered pixel boundaries.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 133de

Numeric cells now align with their right-aligned headers, with regression coverage for formatting variants and rendered output. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: right-aligning numeric table cells with their headers.
Linked Issues check ✅ Passed Issue #1044 requires right alignment for data cells under right-aligned headers and regression tests. table_png.py now computes text_x from the right cell edge with right padding and text width wh…
Out of Scope Changes check ✅ Passed The changes are limited to the table PNG renderer and its regression tests. The tests support Issue #1044 by checking coordinate calculations and rendered PNG alignment. No unrelated production behavi…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-1044-table-cell-alignment

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Workflow state fingerprint for Keepalive Loop Reporter. Do not edit.

@stranske-keepalive

stranske-keepalive Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

🤖 Keepalive Loop Status

PR #1051 | Agent: Claude | Iteration 1/12

Current State

Metric Value
Iteration progress [#---------] 1/12
Action run (verify-acceptance)
Agent status ✅ ALL TASKS COMPLETE
Gate success
Tasks 4/4 complete
Timeout 45 min (default)
Timeout usage 13m elapsed (29%, 32m remaining)
Keepalive ✅ enabled
Autofix ❌ disabled

Last Claude Run

Result Value
Status ✅ Success
Changes ⚪ No changes

Claude output:

All checks confirm the implementation matches the documented fix and test coverage is thorough. Now producing the verdict. Verdict: PASS ## Scope Check - Files in diff: 2 - Files matching scope: 2 - Out-of-scope files: none (Scope per issue #1044: src/counter_risk/renderers/table_png.py and `tests...

🧠 Task Analysis

| Provider | 🔶 Regex (fallback) |
| Confidence | 30% |

⚠️ Primary provider (GitHub Models) was unavailable; used Regex (fallback) instead.

@stranske-keepalive

stranske-keepalive Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor
Keepalive Work Log (click to expand)
# Time (UTC) Agent Action Result Files Tasks Progress Commit Gate
0 2026-09-12 09:10:18 Codex wait (gate-cancelled-transient-transient) skipped 0 4/4 cancelled
0 2026-09-12 09:11:05 Codex wait (gate-cancelled-transient) skipped 0 4/4 cancelled
0 2026-09-12 09:11:55 Codex skip (needs-human) skipped 0 4/4
0 2026-09-12 09:12:32 Codex skip (needs-human) skipped 0 4/4 cancelled
0 2026-09-12 09:21:36 Codex skip (needs-human) skipped 0 4/4 success
0 2026-09-12 09:29:04 Codex wait (gate-not-success) skipped 0 4/4
1 2026-09-12 09:41:36 Claude run (verify-acceptance) success 0 4/4 success

@github-actions

github-actions Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Workflow state fingerprint for Agents Gate Followups. Do not edit.

@stranske

Copy link
Copy Markdown
Owner Author

Autofix attempts exhausted for this head.
Attempts: 9 / 3

Latest Gate summary:

Gate run: https://github.com/stranske/Counter_Risk/actions/runs/34685113700
Conclusion: cancelled
PR: #1051
Head SHA: 133def906d57f58b4cae35c7ef0d368721132d19
Autofix attempts for this head: 9 / 3
Fix scope: src/, tests/, tools/, scripts/, agents/, templates/, .github/
Failing jobs:
- classify changed paths (cancelled)

Please investigate manually.

@stranske
stranske deployed to agent-standard September 12, 2026 09:11 — with GitHub Actions Active
@stranske
stranske deployed to agent-standard September 12, 2026 09:11 — with GitHub Actions Active

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Aligns numeric PNG table cells with right-aligned headers while preserving counterparty name alignment.

Changes:

  • Applies rendered-width positioning to numeric cells.
  • Adds coordinate and decoded-PNG regression tests.
File summaries
File Summary
tests/renderers/test_table_png.py Verifies alignment coordinates and rendered pixels.
src/counter_risk/renderers/table_png.py Applies right alignment to numeric data cells.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@stranske
stranske deployed to agent-standard September 12, 2026 09:11 — with GitHub Actions Active
@stranske
stranske deployed to agent-standard September 12, 2026 09:11 — with GitHub Actions Active
@stranske

Copy link
Copy Markdown
Owner Author

Autofix attempts exhausted for this head.
Attempts: 10 / 3

Latest Gate summary:

Gate run: https://github.com/stranske/Counter_Risk/actions/runs/34685114607
Conclusion: cancelled
PR: #1051
Head SHA: 133def906d57f58b4cae35c7ef0d368721132d19
Autofix attempts for this head: 10 / 3
Fix scope: src/, tests/, tools/, scripts/, agents/, templates/, .github/
Failing jobs:
- Python CI / python 3.12 (cancelled)
  - steps: Restore CI artifact cache (cancelled)
- Python CI / python 3.13 (cancelled)
  - steps: Cache mypy state (cancelled)

Please investigate manually.

@stranske

Copy link
Copy Markdown
Owner Author

Closer audited exact head 133def906d57f58b4cae35c7ef0d368721132d19 against source #1044 and the complete two-file diff. The shared renderer applies the requested right-padding calculation; coordinate and decoded-PNG regressions cover both table variants. The opener recorded 45 passing tests, 8 deliberate-break failures and restored 45 PASS. CodeRabbit reviewed this exact head with no actionable findings; Copilot independently recommends approval on the same head. The optional docstring warning adds no acceptance or correctness debt.

The needs-human label is stale automation state: its two comments cite cancelled Gate runs 34685113700 and 34685114607, not an unresolved product failure or owner decision. Their replacement, Gate 34685167265, completed SUCCESS on this exact head at 09:21 UTC, with both Python versions, Ruff, mypy, conformance and gate-summary passing. Removing the stale label; no retry or additional runner is needed for completed work.

Check-presence audit fetched all 196 check runs and compared them with 234 runs from the recent merged #1043 head. All latest named contexts pass or are intentionally skipped. Six absent nested contexts belong to conditional PR metadata handling and the post-merge verifier; their parent jobs reported SKIPPED, and source/PR routing and body are already complete. They are not missing product tests. Python CI / lint-format is intentionally disabled by format_check: false in the unchanged Gate configuration; Ruff passes. GitHub reports no branch protection and no rulesets, so the lane's explicit gates remain authoritative.

The head has not changed since PR creation at 09:09:38 UTC; the conservative recorded push floor 09:17:32 UTC has elapsed. Full review-thread pagination reports zero active threads. A final unchanged-head, mergeability and check requery precedes merge. After merge, apply verify:compare and retain source #1044 open until its durable report is dispositioned.

@stranske
stranske merged commit fc5301a into main Sep 12, 2026
195 of 202 checks passed
@stranske stranske added the verify:compare Runs verifier comparison mode after merge label Sep 12, 2026
@stranske
stranske deployed to agent-standard September 12, 2026 09:28 — with GitHub Actions Active
@stranske
stranske deployed to agent-standard September 12, 2026 09:28 — with GitHub Actions Active
@stranske
stranske deployed to agent-standard September 12, 2026 09:28 — with GitHub Actions Active
@stranske
stranske deployed to agent-standard September 12, 2026 09:28 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

Provider Comparison Report

Provider Summary

Provider Model Verdict Confidence Summary
openai gpt-5.6-terra PASS 98% The renderer now computes data-cell X positions using the same right-boundary and padding calculation as headers whenever column.header_align is "right", while retaining existing left alignment for...
anthropic claude-sonnet-5 PASS 85% The PR correctly implements the fix requested in issue #1044: numeric cell text for columns with header_align == 'right' is now positioned using the same right-alignment formula used for headers (x...
📋 Full Provider Details (click to expand)

openai

  • Model: gpt-5.6-terra
  • Verdict: PASS
  • Confidence: 98%
  • Scores:
    • Correctness: 10.0/10
    • Completeness: 10.0/10
    • Quality: 9.0/10
    • Testing: 10.0/10
    • Risks: 10.0/10
  • Summary: The renderer now computes data-cell X positions using the same right-boundary and padding calculation as headers whenever column.header_align is "right", while retaining existing left alignment for other columns. This directly satisfies the issue requirement for numeric columns. The added tests intercept draw calls to assert exact X-coordinate/right-padding behavior across both renderers and formatting profiles, and include PNG-level regression coverage. Reverting the conditional calculation to left alignment would cause the coordinate assertions to fail. The change is narrowly scoped, readable, and presents no meaningful compatibility, security, or performance risk.

anthropic

  • Model: claude-sonnet-5
  • Verdict: PASS
  • Confidence: 85%
  • Scores:
    • Correctness: 9.0/10
    • Completeness: 9.0/10
    • Quality: 8.0/10
    • Testing: 8.0/10
    • Risks: 9.0/10
  • Summary: The PR correctly implements the fix requested in issue [P2] Right-align numeric data cells under right-aligned column headers in pure-Python table PNG renderer #1044: numeric cell text for columns with header_align == 'right' is now positioned using the same right-alignment formula used for headers (x + col_width - _CELL_PADDING_X - text_width), while other columns remain left-aligned. This directly resolves the reported misalignment between right-aligned headers and left-aligned data cells. Both required test additions are present: a unit test asserting text_x calculations for right-aligned vs left-aligned columns, and a regression test that decodes actual PNG pixel data to verify visual alignment of numeric cells under right-aligned headers. The change is minimal, scoped, and low risk, with no changes to unrelated rendering logic. Testing gaps are minor (test assumptions tied to specific column layout) but do not undermine the core correctness of the implementation. CI status is not evaluated per instructions since this is a post-merge review.
  • Concerns:
    • The unit test's alignment check assumes column index 0 is always left-aligned and all others right-aligned, an implicit assumption tied to the current _DEFAULT_COLUMNS layout rather than a fully general check of column.header_align.
    • The deliberate-break gate criterion from the issue (temporarily reverting the alignment formula to confirm the test fails) is a manual verification step and cannot be confirmed from the diff alone, though this does not affect the shipped code.

Agreement

  • Verdict: PASS (all providers)
  • Correctness: scores within 1 point (avg 9.5/10, range 9.0-10.0)
  • Completeness: scores within 1 point (avg 9.5/10, range 9.0-10.0)
  • Quality: scores within 1 point (avg 8.5/10, range 8.0-9.0)
  • Risks: scores within 1 point (avg 9.5/10, range 9.0-10.0)

Disagreement

Dimension openai anthropic
Testing 10.0/10 8.0/10

Unique Insights

  • openai: The renderer now computes data-cell X positions using the same right-boundary and padding calculation as headers whenever column.header_align is "right", while retaining existing left alignment for other columns. This directly satisfies the issue requirement for numeric columns. The added tests i...
  • anthropic: The unit test's alignment check assumes column index 0 is always left-aligned and all others right-aligned, an implicit assumption tied to the current _DEFAULT_COLUMNS layout rather than a fully general check of column.header_align.; The deliberate-break gate criterion from the issue (temporarily reverting the alignment formula to confirm the test fails) is a manual verification step and cannot be confirmed from the diff alone, though this does not affect the shipped code.

🔍 LangSmith Traces

@github-actions

Copy link
Copy Markdown
Contributor

Workflow state fingerprint for Agents Verifier. Do not edit.

@github-actions

github-actions Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Runner dispatch state for claude on PR #1051. Do not edit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:codex Assign to Codex agent agents:keepalive Enable keepalive monitoring on PR autofix Let bots format/lint automatically codex verify:compare Runs verifier comparison mode after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P2] Right-align numeric data cells under right-aligned column headers in pure-Python table PNG renderer

2 participants